package com.example.zlpermissionservice.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Author zhenliu（孙凌岳）
 * @Description AI生成 - Swagger配置
 * @Date 2025/6/15 12:05
 * @Version 1.0
 */
@Configuration
@EnableOpenApi // 适配 Swagger 3.x
public class SwaggerConfig {

    @Bean
    public Docket userApi() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("用户权限接口")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.zlpermissionservice.controller")) // 实际的 Controller 包
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("权限服务 API 文档")
                .description("提供权限服务相关接口的文档说明")
                .version("1.0.0")
                .contact(new Contact("zhenliu（孙凌岳）", " ", "23684100997@qq.com"))
                .build();
    }
}
